//
//  UITextViewSimpleViewController.m
//  UITest
//
//  Created by wp w on 12-6-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "UITextViewSimpleViewController.h"
@implementation UITextViewSimpleViewController

UITextView *myTextView;

-(void)buttonClick:(id)sender
{
    [myTextView resignFirstResponder];
}

- (void)viewDidLoad {
	
	[super viewDidLoad];
	
    //新建btn
	CGRect buttonFrame = CGRectMake(10,15,60,32);
	UIButton *keyboardToggle = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	[keyboardToggle setTitle:@"hide" forState:UIControlStateNormal];
	[keyboardToggle addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
	keyboardToggle.frame = buttonFrame;
    [self.view addSubview:keyboardToggle];
	
    //新建textview
    //当显示键盘时，会把文本框覆盖
	CGRect textRect = CGRectMake(10,60,300,200);
	myTextView = [[UITextView alloc] initWithFrame:textRect];
	
	myTextView.font = [UIFont systemFontOfSize:22.0];
	
	myTextView.keyboardType = UIKeyboardTypeDefault;
	myTextView.returnKeyType = UIReturnKeyGo;
	
    //如果想要检测超链接或者电话号码等，就要如下设置
//	myTextView.text = @"this is a link: http://google.com ";
//	myTextView.dataDetectorTypes = UIDataDetectorTypeAll;
//	myTextView.editable = NO;
	
	myTextView.delegate = self;
	
	[self.view addSubview:myTextView];
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [myTextView release];
    
    [super dealloc];
}

@end
